package com.example.myspringboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.myspringboot.domain.ImChatUserGroupMessage;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.data.elasticsearch.annotations.Query;

import java.util.List;

/**
* @author zheng
* @description 针对表【im_chat_user_group_message(群聊记录)】的数据库操作Mapper
* @createDate 2024-05-17 18:05:16
* @Entity generator.domain.ImChatUserGroupMessage
*/
@Mapper
public interface ImChatUserGroupMessageMapper extends BaseMapper<ImChatUserGroupMessage> {

    /**
     * 模糊匹配公司名称
     * @param companyNameRegex 分词后的公司名称
     * @param companyName 分词前的公司名称
     * @return
     */
    @Query(value ="SELECT * FROM im_chat_user_group_message WHERE isDeleted = '0' AND companyName REGEXP ?1 " +
                    "ORDER BY (length(companyName) - length(REPLACE(companyName, ?2, ''))) DESC")
    List<ImChatUserGroupMessage> queryMatchCompanyName(String companyNameRegex, String companyName);


}




